perm filename PREAMB.OLD[SYS,HE]1 blob sn#048166 filedate 1973-06-14 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00016 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00003 00002	REQUIRE  37 VERSION
C00007 00003	Comment     SECTION 1 -- The Models - the 3-D TABLE MODEL
C00010 00004	Comment   2D MODEL   [SET UP BY CURVE FITTER]
C00012 00005	Comment  2D REGION MODEL
C00015 00006	Comment  3D MODEL -- objects in the world.
C00018 00007	Comment  CAMERA MODEL
C00022 00008	Comment		 SECTION 2 --   Logical job names and flags
C00026 00009	SECTION 3 - JOB SPECIFIC MPs AND DATA - HE AND GENERAL
C00028 00010	Comment 	**** EDGE ****
C00031 00011		**** VERIFIER  AND CAMERA ****
C00033 00012	Comment			SIMPLE
C00035 00013	YOU have found the COMPLEX page
C00038 00014	comment		COLOR , EYE, AND AUTOFOC
C00041 00015	comment			*** HAND ***
C00056 00016	Comment	CURVE and  ACCOMODATION
C00059 ENDMK
C⊗;
REQUIRE  37 VERSION;
COMMENT THIS NUMBER SHOULD BE UPDATED EVERY TIME A
		VARIABLE OR ITEM IS CHANGED IN ANY WAY
	THIS IS FILE PREAMB.TXT ON [II,HE]

After a title like that, anything like what follows must be considered
anti-climactic.  However, in order to eventually say END "HAND EYE SYSTEM",
we must dig in and make a start.

This file is divided into sections:
	1. The MODELS... The data representations which, to some
		extent, everyone must know about.
	2. The once_per_module data.  These include display variables,
		debugging permissions, etc.
	3. The local message procedure definitions and the semi-local
		data definitions.  These are variables which
		do not qualify under 1 or 2, but which are needed.
;
Comment     SECTION 1 -- The Models - the 3-D TABLE MODEL

;


Comment TABLE MODEL -----    [not currently used]
   This consists of an itemvar array TABLE, whose  indices  are  x/4,y/4
   where  x  and  y are in inches, and are table coordinates. Initially,
   TABLE[i,j] is filled up with a shiny  global  item,  if  TAB_INIT  is
   TRUE. As things become known about this element, various associations
   on this item are made:

	the item for each index has an integer datum decoded as follows:
		0	grid square not scanned yet
		1	grid square completely scanned and is empty
		-1	grid square at least partially scanned and
			contains something, according to the associations.

	BLOB ⊗ TABLE[i,j] ≡ blobs known to be located in this area
		This is the first association created.  When the blob
		has been recognized completely,  this association is
		replaced by
	ON ⊗ TABLE[i,j] ≡  objects known to be located in this area
	HIDDEN ⊗ TABLE[i,j] ≡ objects hiding the area
		The squares containing this association for a given object
		are those which were covered by the BLOB association but
		not the ON association.
	HEIGHT ⊗ TABLE[i,j] ≡ and item whose real datum is the height, in
		inches of the highest point of an object which occupies
		this square.

;

Global Itemvar Array TABLE[0:11,0:19];
Global Item    ON,HEIGHT,BLOB,HIDDEN;
Global Boolean    TAB_INIT;
Comment   2D MODEL   [SET UP BY CURVE FITTER]

	The 2D model is basically concerned with those elusive entities,
	BLOBs.  Each blob is represented by a global item, with some
	information saved about it.

	The description of the entire structure can currently be found
		in the edge follower documentation file,
		EDGCUR.LST[SYS,HE].  Below is one association to start 
		you off.

	XFORM ⊗ blob ≡  an item whose datum is the current camera transform.
		See camera stuff below.

	BLOBS contains a set of BLOB items stored there by K. Pingle which
		are now ready to be processed.;

Global set     BLOBS;

Global Item XFORM, BACKGROUND, REGION, PERIMETER, ENDPT, LINE, DANGLE;
Comment  2D REGION MODEL
	[SET UP BY SIMPLE - CURRENTLY NOT USED BY ANYONE ELSE]

NOTE:  MORE INFORMATION ON COMPLEX PAGE !!!

This is the results of a region analysis of the scene.  This model will
not necessarily reside in the global data area.  However, there is no harm
in declaring its attributes to be global, so the description is included
here for clarity.

The basic unit is the SCENE.  We then make associations to locate
various objects in the scene:

	BACKGROUND ⊗ scene ≡  some specific region.
	REGION ⊗ scene ≡ all separate regions in the scene.
	BOUNDARY ⊗ region ≡ lines
	CORNER ⊗ region ≡ points
	ENDPOINT ⊗ lines ≡ points

Further, there is something linking the scene and its source blob, e.g.

	REGION_ANALYSIS ⊗ blob ≡ scene

The datums of things are quasi-important:

	datum (endpoint) is a real array [1:6]
		1-4  x,y,z,w  on table
		5,6  x,y screen coords.

;

Global Item PTYPE,RPP,WEDGE,SCENE,CORNER,VERTEX,BODY,POINT,EDGE,
	BASE,ATR,OCCLUDER,ABOVE,PARENT,SON,FLAVOR,BOUNDARY,
	TJOINT,BADT,MULTI,KJOINT,GOODX,BADX,ARROW,BADARO,GOODY,BADY,
	GOODL,BADL;


COMMENT The GLOBAL MODEL contains a set of all the prototype names
	contained in the GLOBAL MODEL;

GLOBAL SET PROTOTYPES;

Comment -- NOTA BENE   This previous description is wrong.
	Kicha -- correct please;
Comment  3D MODEL -- objects in the world.
	[SET UP BY IIDRV AND SIMPLE - USED IN IIDRV]

This is the model which represents things found and completely
recognized.  However, information may be partially missing (e.g. the
colors of all faces may not yet be known).

The main association is: INSTANCE ⊗ prototype ≡ object.

Datum (obj) is the transform a la Gil, which takes the prototype coordinates
into a location for the object.

Each object may have a wealth of things stored about it:

	EDGES⊗object≡ an item whose datum is an array identical to that for
		INSIDE_EDGES containing all visible edges of the object.
		It is made by SIMPLE for the use of II and EDGE.

	FAi are global items designating the faces of the objects

	FACE⊗object≡FAi		one of these for each face of each object

	VISIBLE⊗object≡FAi	one of these for each visible face

	NORMAL⊗FAi≡ the normal vector to the center of FAi

	CENTER⊗FAi≡ a two element integer array giving the center
		of the face in TV coordinates.

	COLOR⊗FAi≡some color.
;
Global Item INVERSE,CONCAVE,SHAPE,INSTANCE,COLOR,SIZEOBJ,LEFT,RIGHT,
	SUPPORTER, EDGES,CENTER,FACE, NORMAL, VISIBLE;
Global Integer Item BLUE,GREEN,RED,WHITE,ORANGE,YELLOW;

Comment	so that people can know what is around in the global model by
way of prototypes, SIMPLE makes the following assertion:

	PROTOTYPE⊗SCENE≡prototype_name 		AND,therefore:;

GLOBAL ITEM PROTOTYPE;

Comment also the prototype names;

Global Item RPP114,RPP112,RPP122,RPP124,WEDGE122,WEDGE124,RHOMBOID,LBEAM,
	CUBE, BOX;

Global Integer GOT_MODELS; comment set if the global prototypes are read in;
Comment  CAMERA MODEL

This model has all good things about the camera.

There is an itemvar array called CURCAM which contains an
item for each camera  whose datum is an array which completely
describes the view from the camera.All references to TRANSFORMs are
references to items of this variety.;

Global Real Array CAMERA_MODEL,CAMERA_PREDI[1:10,1:3];
	Comment  1:3,1:3 is colineation matrix (TABLE → SCREEN),
		  4 ,1:3 is lens center coords
		  5 ,1:2 screen coords of Piercing Point
		 6:8,1:3 inverse colineation matrix (SCREEN→TABLE)
		  9 ,1:3 CAMPAN, CAMTIL, CAMRANG
                  10,1:2 CAMERA NO.,CAMLENS (or zoom focal length)
		 MODEL has the current transform for the camera number
		in CAMNUM, PREDI has the predicted 
		 transforms for the point req. last in CAM_PRED;

GLOBAL INTEGER CAMFLG,CAMLENS,CAMNUM;
GLOBAL REAL CAMPAN,CAMTIL,CAMRANG;
Global Real Array Itemvar Array CURCAM[1:2];
GLOBAL REAL ARRAY A_REC,AI_REC[1:3,1:3],LENS_REC[1:3];
Global Real PANPOT,TILPOT,FOCPOT,ZOOPOT;

Comment    CORNER FINDER(EYE) MODEL;
 
GLOBAL INTEGER EYEFLG;
GLOBAL REAL ARRAY DIR_EYE[0:10,1:8];
comment	 DIR[.,I], I=1,...,4 -  direction cosines of corner sides
	 DIR[.,5],DIR[.,6]-screen coords of corner
	 DIR[.,7]=0 if corner, 1 if line
	 DIR[.,8]=0 if match, 1 if only 1st. edge match, 2 if 2nd. match
	 different rows are for different features found in the same window;
GLOBAL INTEGER ARRAY LOOK_AT[1:8];
comment	LOOK_AT[1]-camrea number: 1-old camera, 2-new camera(don`t use yet)
	LOOK_AT[2],LOOK_AT[3]-screen coordinates of center of window
	LOOK_AT[4]-width of window
	LOOK_AT[5]-hight of window
  	LOOK_AT[6],LOOK_AT[7]-TCLIP,BCLIP
	LOOK_AT[8]-sensitivity;

comment	  AUTO FOCUSSING MODEL;

GLOBAL INTEGER FOCFLG;
comment for error indication;
GLOBAL REAL FOCRANG,FOCDELF;
comment FOCRANG is the range estimate to best focus.
	FOCDELF is the estimate of range uncertainty;
Comment		 SECTION 2 --   Logical job names and flags

These logical names are those for the global flags only.  They should
not be confused with the logical names used by the message procedure
routines or by and hand/eye monitor, although it would be nice if they
were all the same.

Table of logical names:

EDGE		EDGE FOLLOWER
CUR		CURVE FITTER
SIMP		SIMPLE BODY RECOGNIZER
CAM		THE CAMERA MOVER AND TRANSFORM MAKER
VER		J.M. Tenenbaum's  line verifyer
SEG		THE SEGMENTER - PART OF COMPLEX BODY RECOGNIZER
REC		THE COMPLEX -SCENE DESCRIBER - 	"
PRED		PREDICTOR-HIDDEN LINE ELIMINATOR -   "
COL		Color recognizer.
HAND		The arm program
MOVE		Yet another arm program - two arms are better than one
GUN		GUNNAR'S REGION FINDER
DRV		CONTRL PROGRAM
EYE		Gill's corner search and match, you are welcome to try it.
FOC		Automaic-Focus. Ask J.M.T  about thery, Gill about practice.

Template data:

DEB_@		If TRUE, you may put debugging information on the disk.
DIS_@		If TRUE, you may disply to your heart's content.
YES_@		You should set to TRUE as you initialize.
TYP_@		You may type out anything you please -- don't go into wait

BELOW ARE THE CURRENTLY USED GLOBAL FLAGS;

Global Integer DEB_EDGE,DIS_EDGE,YES_EDGE,TYP_EDGE;
GLOBAL INTEGER DEB_CUR,DIS_CUR,YES_CUR,TYP_CUR;
Global Integer DEB_SIMP,DIS_SIMP,YES_SIMP,TYP_SIMP;
Global Integer DEB_CAM,DIS_CAM,YES_CAM,TYP_CAM;
Global Integer DEB_VER,DIS_VER,YES_VER,TYP_VER;
Global Integer DEB_COL,DIS_COL,YES_COL,TYP_COL;
Global Integer DEB_II,DIS_II,YES_II,TYP_II;
GLOBAL INTEGER DEB_GUN,DIS_GUN,YES_GUN,TYP_GUN;
GLOBAL INTEGER DEB_EYE,DIS_EYE,YES_EYE,TYP_EYE;
GLOBAL INTEGER DEB_HAND,DIS_HAND,YES_HAND,TYP_HAND;
GLOBAL INTEGER DEB_MOVE,DIS_MOVE,YES_MOVE,TYP_MOVE;
Global Integer DEB_SEG,DIS_SEG,YES_SEG,TYP_SEG;
Global Integer DEB_REC,DIS_REC,YES_REC,TYP_REC;
Global Integer DEB_PRED,DIS_PRED,YES_PRED,TYP_PRED;
Global Integer DEB_FOC,DIS_FOC,YES_FOC,TYP_FOC;
COMMENT	SECTION 3 - JOB SPECIFIC MPs AND DATA - HE AND GENERAL;

Define mp="Forward Message Procedure";
Define smp="Forward Simple Message Procedure";

comment		the run number if HE is controling this mess, 0 otherwise;

global internal integer RUN;

comment		the message procedure trace flag, which is defined in the 
		second segment runtime routines;

EXTERNAL BOOLEAN TRACING;

comment	misc. items for communicating with the edge follower;

GLOBAL ITEM NIL, EVERY;

Comment table of free display frames for h/e version of Quam display code;

GLOBAL INTEGER ARRAY GDISP[0:14];

Comment this is the initialization flag for GDISP;

GLOBAL INTEGER GDISP_INIT;

comment	this is the monitors only public message procedure,
	TRACE can only be called from the second segment;

smp MON_COM(string command);

Comment	=-1 if monitor on data disk, 1 if on III, 0 if no monitor;

GLOBAL INTEGER DISDEV;

COMMENT for various MPs to get object;

Global Real Array Itemvar ITVAR_II;

COMMENT for various MPs to get status;

GLOBAL INTEGER STAT_II;
Comment 	**** EDGE ****

For a detailed description of these procedures, see EDGCUR.LST[SYS,HE].
Only the definitions themselves are given here.;

COMMENT		MISC. PROCEDURES;

mp GETDATA ( LIST arg; reference boolean flag);
smp DISK ( string name; reference boolean flag);
smp XEQ ( string command; reference boolean flag);
smp SETVAL ( string name; integer val; reference boolean flag);
MP GLBDMP(SET A);
MP GETSTAT(LIST ARG; REAL TOP,BOT,LEFT,RIGH; REFERENCE BOOLEAN FLAG);

comment		main calls;

mp FIND ( ITEMVAR arg );
mp RELOOK ( ITEMVAR arg; INTEGER x, y ); 
mp FIT ( ITEMVAR arg );
mp COMPACT ( ITEMVAR arg );
mp REJECT ( ITEMVAR arg );
MP FINE(ITEMVAR ARG);

Comment these last six return a message (to be found in you the caller):;

mp RESPONSE ( string name; integer arg; integer status );

Comment  this sends edge points to requesting job (found in caller);

MP SEND_DATA ( INTEGER COUNT; REAL ARRAY DAT);

COMMENT this send object data and segment status to requesting job;

MP SEND_STATUS(INTEGER OC;REAL ARRAY S);

comment	the next message links to the curve fitter;

MP CURVE_FIT(REAL ARRAY DATA);

COMMENT This is the edge followers very own set (no pun intended).;
GLOBAL SET OLDBLOB;

comment item for GETSTATUS command's internal structure;

GLOBAL ITEM SEGM;
COMMENT		**** VERIFIER  AND CAMERA ****;

mp VERIFY(INTEGER X1, Y1, X2, Y2; REFERENCE REAL CONF);
COMMENT CONF IS CONFIDENCE;

GLOBAL REAL CONFID;	COMMENT THIS IS TO RETURN CONF;

Comment 		CAMERA

For now, this is very simple, and will merely involve reading a
camera model from the disk, reading pan tilt pots, and creating
the matrices described in the camera model.
Now, at last, we are more sofisticated: you can also MOVE the camera!
;

SIMPLE mp CAM_UPDATE(INTEGER CAMNUM);
SIMPLE mp CAM_INIT(INTEGER CAMNUM);
   comment read in an initialized model...;

SIMPLE mp CHNG_LENS(INTEGER LENS);
   comment 1-25mm, 2-50mm, don't try other yet. CAMERA 1 ONLY;

SIMPLE mp MOVE_CAM(INTEGER CAMNUM; REAL PAN,TILT);
   comment PAN from -X into table, TILT from horizon down, in RADs;

SIMPLE mp CHNG_FOCUS(INTEGER CAMNUM; REAL RANGE);
   comment RANGE in inchs;

SIMPLE mp CHNG_ZOOM(REAL FOC_LGTH);
    comment FOC_LGTH in inches;

SIMPLE mp CAM_CENTER(INTEGER LENS,CAMNUM; REAL X,Y,Z);
   comment X,Y,Z, in table coordinates;

SIMPLE mp CAM_PRED(INTEGER LENS,CAMNUM; REAL X,Y,Z);
   comment X,Y,Z, in table coordinates;

Comment			SIMPLE

These are preliminary at best.
Prototypes must be in the global segment specified when running SIMPLE.
The global segment can be created by running MAKSEG.DMP on [SYS,HE].

Simplefit is called to try to recognize the blob.  Status is returned.
;


mp SIMP_FIT(item blob;reference integer status;
	reference real array itemvar x);

Comment Status is returned .....
	0 -- perfect match to a prototype.  The new item created
		for the instance is in x.
	-1 -- no BOUNDARY or TRANSFORM information in global model.
	1 -- wrong number of outside edges for us.
	2 -- screwup in matching process.

;
mp SIMP_UPDATE(real array itemvar obj;real array trans;
	reference integer stat);

COMMENT adjusts the world model for obj being moved TO (underlined and
	italicized) trans;
COMMENT	YOU have found the COMPLEX page

Some words about the model are in order here (i think)...
COMPLEX wants the following global model associations:

GLOBAL INPUT MODEL:

	POINT⊗<scene>≡<point>
	LINE⊗<scene>≡<line>
		ENDPT⊗<line>≡<point 1>
		ENDPT⊗<line>≡<point 2>
	REGION⊗<scene>≡<region>
		PERIMETER⊗<region>≡<list item>
	BACKGROUND⊗<scene>≡<region>
	TRANSFORM⊗<scene>≡<array item>

with the following datums:
	∂(<point>)=<array item> s.t.
		∂(<pt>)[1]= tv x coor
		∂(<pt>)[2]= tv y coor
		∂(<pt>)[6]= display x coor
		∂(<pt>)[7]= display y coor
	∂(<list item>) = list of vertices around the regions
	∂(<array item>) = 10 x 3 camera transform
	
after sufficient thrashing around a description of the above input
data is put out in the form of bodies:

GLOBAL OUTPUT MODEL:

	BODY⊗<scene>≡<body>
		LINE⊗<body>≡<line>
		POINT⊗<body>≡<point>
		REGION⊗<body>≡<region>
			BOUNDARY⊗<region>≡<line>
			CORNER⊗<region>≡<point>


COMPLEX currently consists of three jobs:
	RECOGNIZER	JOB1
	SEGMENTER	JOB2
	PREDICTOR	JOB3

The order of operation is:
1	JOB1 calls JOB2
2	JOB2 separates the scene and supplies support and occluder
	data for the global model
3	JOB1 returns to do its recognizer thing
4	then JOB1 calls JOB3 to verify that it got the right answer
;


COMMENT THE RECOGNIZER;
FORWARD MESSAGE PROCEDURE ANALYZE(ITEMVAR BLOB);
FORWARD MESSAGE PROCEDURE PREDICT;

COMMENT THE SEGMENTER;
FORWARD MESSAGE PROCEDURE SEGMENT(ITEMVAR BLOB);


COMMENT	PREDICTOR-HIDDEN LINE ELIMINATOR;
FORWARD MESSAGE PROCEDURE
	CHECK (ITEMVAR BLOB);




comment		COLOR , EYE, AND AUTOFOC;
comment		this is for the old color program of TOB;

mp CLR_GET ( INTEGER N; REAL ARRAY POINTS);
	Comment call to get colors for points. POINTS is indexed
		by [1:2,1:N] for x,y screen coords of places to look;

mp CLR_RESPONSE ( INTEGER ITEMVAR ARRAY GJ);
	Comment this is the response for colors;

comment		this is for the new colour program of AJT;

MP COLOUR_INIT(INTEGER ARRAY TV; INTEGER STEP,CAM,MULT,BC);
MP C_INIT(INTEGER TV, POINTS);
MP COLOUR(INTEGER COL; INTEGER ARRAY POINTS);
MP COLOUR_RECEIVE(INTEGER COL; INTEGER ARRAY COLOUR_MAP);



comment		EYE;

SIMPLE mp SRCH_IMAGE(INTEGER BKGR,INT,SEARCH; REAL TOLER; REAL ARRAY DIRD);
comment Jack_of_all_trades, see explanation below
	BKGR- -1 for dark background, 1 for light background, 0 for either
	INT-intensity match 1-for darker inside, -1-for lighter inside, 
		            0-for no match
        SEARCH-width of window to search (in LOOK_AT[4] units,
	       0 for no search but recentering allowed,
	       if SEARCH<0 -SEARCH is the number of features looked for
	TOLER-tolerance for matching .05 is a good number, -1 for no match;

SIMPLE mp SET_WINDOW;
comment for testing and helping purposes;

comment   AUTOFOC;

mp AUTOFOC(REAL EST_RANG,RANGINVAL; INTEGER NCUT);
comment EST_RANG: initial estimataed range in inches.
        RANGINVAL: initial range uncertainty in inches.
        NCUT: value of CUT (0 to 15. usually 4) or -1 for automatic;
comment			*** HAND ***
;
DEFINE TSX="1.0017",TSY="1.0028";
comment	where real x = table x * tsx  and real y = table y * tsy
	these are the conversion factors from table inches to real inches;
GLOBAL INTERNAL INTEGER ARM_MOTION,ARM_STATUS,ARM_SEGMENT,ARM_WAIT,
	ARM_TIME,ARM_EXECUTE;
comment	ARM_MOTION contains the file name (in sixbit) of the trajectory
	being executed with the arm in motion, it is set to zero on the
	completionof execution.
	If an execution error occurs ARM_MOTION is cleared and the
	file nameis set into ARM_WAIT.
	ARM_STATUS at the completion of execution of each trajectory
	is set as follows:
		0	all O.K.
		1	overflow occured
		<n>1	execution ended due to excessive force at joint n
		2	grasp error, hand closed less than the min. distance
		3	file not found
		4	enter for data file failed
		5	disk not found
		<n>6	Arm stopped on touching the n'th sensor
		7	A/D read error
		20	excessive time
		22	hand takes excessive time
		23	Arm failed to stop on force limit
		24	Arm in control loop
		25	Save array index out of bounds
		30	the arm is down
		40	message invalid, arm not in wait state
		50	file read error
		60	wrong servo version number
		70	reference supply is off, check fuse and restart job
		100	the PDP-6 is down
		200	PDP-6 Parity error occured

	ARM_SEGMENT initially zero at the beginning of execution of each
	trajectory file is incremented as each part trajectory is started

	ARM_TIME is set to zero by START_TRAJECTORY and is incremented
	by the estimated time in jiffies that the trajectory will take,
	each time MOVE_ARM is called

	ARM_EXECUTE if true the arm function is executed immediately,
	in the case of trajectory functions the hand is moved but in the
	manner of a change;


GLOBAL INTERNAL BOOLEAN STOP_ON_TOUCH;
comment	if this is true the arm will stop if it touches anything that it
	can feel during any trajectories executed after it is set;

FORWARD MESSAGE SIMPLE PROCEDURE SET_TOUCH(BOOLEAN STOP_ON_TOUCH);
comment	this is a planning function and allows the touch state to be
	changed during execution for the next function;

GLOBAL INTERNAL INTEGER ARRAY FELT[1:2,1:4,1:4];
comment	if the arm stops on touching something this contains the
	information as to which element did the touching;

GLOBAL REAL ARRAY ARM_LINK[3:6,1:4,1:4];
comment	These 4, 4x4 arrays contain the current positions of the last four
	links of the arm. They are updated after every arm motion, and
	when the arm is in the wait state;

GLOBAL REAL GRASP;
comment	This contains the opening between the fingers in inches;

SMP ARM_CONO(REAL ARRAY ARRIVE,DEPART,OBJECT;INTEGER ARRIVE_TIME,
	DEPART_TIME);
comment	this is a planning function allowing arrive, depart vectors to be
	set when this message is executed, also object is a 1x4 array
	containing the mass and three radii of gyration of the object to
	be moved;

SMP START_TRAJECTORY(STRING FILE;BOOLEAN START_FROM_LAST);
comment	This procedure is called to start every trajectory, If
	START_FROM_LAST is TRUE then the trajectory  will start from the
	last planned position, otherwise it will start from the present
	arm position, needless to say if the arm isn't physically where
	the trajectory starts from there will trouble;

SMP MOVE_ARM(REAL ARRAY JOINT6; REFERENCE INTEGER FLAG);
comment	This and the next two procedures generate trajectories from the
	last place a trajectory was planned to, to the new position.
	Given a transform for the JOINT6( with the orign located between
	the finger tips and 0.375 inches in, the z axis aligned with the
	fingers and pointing out and the unit y vector pointing from one
	finger tip to the other), this procedure finds an arm solution and
	checks that it does not put the arm through the table or through
	its support post, and generates a trajectory returning TRUE in FLAG;

MP MOVE_INSTANCE(REAL ARRAY ITEMVAR INSTANCE;REAL ARRAY NEW_TRANSFORM,
	INTERMEDIATE_POSITION;REFERENCE INTEGER PLAN);
comment	This procedure generates a trajectory to move the arm from the
	last planned position, to pick up the INSTANCE of some prototype
	and to move it to NEW_POSITION using INTERMEDIATE_POSITION if
	necessary, status is returned in PLAN as follows:
		-1	There is no way the hand can grasp the instance
		-2	Hand cannot reach instance at its initial position
		-3	Hand cannot reach instance at its final position
		-4	There is no way using the present intermediate
			position that the move can be made, another
			INTERMEDIATE_POSITION might help.
		-5	Instance has either too few or too many prototypes
		2	Trajectory generated without intermediate position
		4	Trajectory generated with the intermediate position
	Note if the INTERMEDIATE_POSITION is cleared to zero then the
	instances present position will be used as such
	this message proceedure is now in module "MOVE" which in turn sends
	messages to "HAND",no messages should be sent to HAND until MOVE
	has finished;

SMP PARK_ARM;
comment	Generates a trajectory to the park position;

FORWARD MESSAGE SIMPLE PROCEDURE OPEN_HAND(REAL OPENING);
comment	This causes the hand to open or close to OPENING at this point in
	the trajectory if opening it does not stop on touch;

FORWARD MESSAGE SIMPLE PROCEDURE CLOSE_HAND(REAL MINIMUN_DISTANCE);
comment	This causes the hand to close at this point in the trajectory,
	and if so doing it closes more than MINIMUN_DISANCE execution is
	stopped and ARM_STATUS is set to 2
	it does not stop on touch;

FORWARD MESSAGE SIMPLE PROCEDURE PLACE_ARM;
comment	This causes the hand to decend vertically until it meets some
	resistance. It should be able to drop approximately 1/2 inch
	before stopping;

SMP CHANGE_ARM(REAL ARRAY DX_DY_DZ;REAL DIST;REAL ARRAY AXIS;REAL DEG;
	INTEGER TIME;REFERENCE INTEGER FLAG);
comment	At this point in the trajectory the arm will make the appropiate 
	differential motion specified by the first three elements of
	DX_DY_DZ scaled by DIST, it will also rotate DEG degrees about
	axis AXIS. The action will take at least TIME jiffies.
	If the motion drives the arm beyond its physical limits no action
	is planed and FALSE is returned;

FORWARD MESSAGE SIMPLE PROCEDURE WAIT_ARM;
comment	This procedure causes the arm to pause in execution and go into
	a wait state;

FORWARD MESSAGE SIMPLE PROCEDURE CLOSE_TRAJECTORY;
comment	This closes the trajectory file, a good idea;

FORWARD MESSAGE SIMPLE PROCEDURE DO_IT(STRING FILE);
comment	This executes trajectory FILE;

FORWARD MESSAGE SIMPLE PROCEDURE DO_PROCEED(BOOLEAN REPEAT);
comment	Execution of this procedure when in the wait state causes the arm
	to proceed with its planned trajectory repeating the last
	instruction if necessary;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_POSITION;
Comment	This causes the arm position to be read and should not be used
	unless the arm has been moved without power on;

SMP STOP_ARM(REAL ARRAY F,V;REFERENCE INTEGER STAT);
Comment	This will cause the arm to stop when it exerts a force or moment
	in the direction specified, if it fails to stop then error 23
	results If stat is false then the force specified is too small
	and no action is planned;
	

FORWARD SIMPLE MESSAGE PROCEDURE ARM_SKIPE(INTEGER ERROR);
Comment	This causes the arm to skip the next function it was going to
	perform if error ERROR occured;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_SKIPN(INTEGER ERROR);
Comment	This causes the arm to skip the next function it was going to
	perform if error ERROR did not occur;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_SKIPs(INTEGER ERROR);
Comment	This causes the arm to skip the next function it was going to
	perform if error ERROR ored with the variable bits occured;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_JMP(INTEGER N);
Comment	This causes the arm to jump backwards or forwards N functions;

FORWARD SIMPLE MESSAGE PROCEDURE MERGE_ARM;
comment	this will cause a preceeding arm function to be performed with the
	move instruction immediately preceeding that function;

FORWARD SIMPLE MESSAGE PROCEDURE CENTER_HAND(REAL MINIMUM_DISTANCE);
comment	this is the same as CLOSE_HAND except that it centers the hand 
	before closing;

SMP DRIVE_ARM(INTEGER JOINT;REAL DEGREES;INTEGER TIME;
	REFERENCE INTEGER FLAG);
comment	causes a singlejoint to be driven;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_SAVE(INTEGER I);
comment	causes the differential deviation to be saved in the i'th cell;

FORWARD SIMPLE MESSAGE PROCEDURE ARM_RESTORE(INTEGER I);
comment	causes the differential deviation to be restored from the i'th cell
	it is executed after a move instruction, and affects that move;

comment			THE ARM'S GLOBALS;
GLOBAL INTERNAL SAFE REAL ARRAY ARM_VECTOR[1:7];
GLOBAL INTERNAL SAFE REAL ARRAY ARM_TORQUE[1:6];
GLOBAL SAFE REAL ARRAY ITEM TEST_BLOCK[1:4,1:4];
GLOBAL INTEGER ARM_PLAN;
GLOBAL SAFE REAL ARRAY FREE_ARM[0:6,1:6];
GLOBAL SAFE REAL ARRAY FORCE_ARM[1:6];
Comment	CURVE and  ACCOMODATION;

GLOBAL INTEGER CURVE_STATUS; COMMENT to return status from CURVE;

comment 	global tolerences for curve fitting;

GLOBAL INTERNAL REAL cur_t1,cur_t2,cur_ml,cur_cl,cur_mx,cur_ld,cur_vd;
GLOBAL INTEGER cur_init;

COMMENT THIS IS IRWIN'S THING ;
GLOBAL INTEGER FLAG_CAM ;


COMMENT  FLAGS AND CALIB. CONSTANTS FOR ACCOMODATION ROUTINES
	 IN EDGE FOLLOWER, COLOR, FOCUS, VERIFIER;

GLOBAL INTEGER COLFILT_ACC;		COMMENT	FILTER COLOR: 0-RED,
					1-BLUE, 2-GREEN, 3-CLEAR;
GLOBAL INTERNAL INTEGER DAC_ACC;	COMMENT CURRENT DAC SETTING;
GLOBAL BOOLEAN CHANGE_ACC;		COMMENT TRUE IF SCENE CHANGED;
GLOBAL	BOOLEAN SENSCAL_ACC;		COMMENT HAS SENS BEEN CALIBRATED;
GLOBAL	BOOLEAN AUTOCAL_ACC;		COMMENT TABLE_ACC INITIALIZED;
GLOBAL INTERNAL INTEGER AUTO_ACC;	COMMENT SETTING OF DAC AT AUTOTARGET
					THRES. FOR CURRENT FILTER;
GLOBAL	INTEGER SENSIGN_ACC;		COMMENT DIRECTION OF LAST CHANGE IN
					TARGET VOLTAGE-TO AVOID LOOPS.
					1: UP, -1: DOWN, 0-NOT YET CHANGED;
GLOBAL INTEGER ARRAY TABLE_ACC[0:63];	COMMENT HOLDS AD READINGS FOR DAC
					SETTINGS;
GLOBAL INTEGER ARRAY FIL_ACC[0:3];	COMMENT AUTO TARGET FOR EACH FILTER,
					0 IF NOT INITED;

GLOBAL REAL FCALPOTC_ACC,FCALPOTD_ACC,F_ACC,FNUM_ACC,CIRCONFUS_ACC;
	COMMENT FOCUS AND LENS CALIBRATION CONSTANTS;

GLOBAL BOOLEAN SENSFLAG_ACC;		COMMENT TRUE-SENSITIVITY CAN SAFELY
						BE RAISED
						FALSE-CANT RAISE
						SENSITIVITY;
GLOBAL BOOLEAN SENDWNFG_ACC;		COMMENT SENSITIVITY CANNOT BE
						LOWERED;